<div class="pa">
  <h2>购物车</h2>
  <hr/>
  <div class="clearfix">
    <table>
      <tr>
        <th>编号</th>
        <th>名称</th>
        <th>价格</th>
        <th>折扣</th>
        <th>数量</th>
        <th>操作</th>
      </tr>
      <% @carts.each do |cart| %>
        <tr>
          <td><%= cart.product.id %></td>
          <td><%= cart.product.name %></td>
          <td><%= cart.product.price %></td>
          <td><%= cart.product.discount %></td>
          <td>
            <%= form_tag '/carts/number' do -%>
              <%= hidden_field_tag 'product_id', cart.product.id %>
              ×<%= text_field_tag 'number', cart.number, :size => '3' %>
              <%= submit_tag '修改数量' %>
            <% end %>
          </td>
          <td><%= link_to '删除', "/carts/delete/#{cart.id}", :confirm => "你确认要将#{cart.product.name}从购物车中清出吗？" %></td>
        </tr>
      <% end %>
    </table>
    <hr/>
    <div class="pa-bottom center">
      <span class="f14 red">总金额：<%= amount @carts %> 元</span>
    </div>
    <hr/>
    <div class="text-right">
      <span><%= link_to '< 继续购买', '/products', :class => 'tdn pa-3 f-border shadow2 radius5' %></span>
      <% if !@carts.blank? %>
        <span><%= link_to '去结算 >', '/deals/new', :class => 'tdn pa-3 f-border shadow2 radius5' %></span>
      <% end %>
    </div>
  </div>
</div>